<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #container {
            width: 600px;
            height: 600px;
            margin: 0px auto;
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
        }

        #container div {
            width: 190px;
            height: 190px;
            background-color: bisque;
            text-align: center;
            line-height: 190px;
            font-size: 24px;

        }

        #container div#button {
            background-color: blue;
            border-radius: 50%;
        }

        #container div.color {
            background-color: aquamarine;
        }
    </style>
</head>

<body>
    <div id="container">
        <div id="box1">奖品一</div>
        <div id="box2">奖品二</div>
        <div id="box3">奖品三</div>
        <div id="box8">奖品八</div>
        <div id="button">开始</div>
        <div id="box4">奖品四</div>
        <div id="box7">奖品七</div>
        <div id="box6">奖品六</div>
        <div id="box5">奖品 五</div>
    </div>
    <script>
        var button = document.getElementById("button");
        var index = 1;
        var last = 8;
        var numner = Math.floor(Math.random
            () * 8 + 1);
        var circle = 0;
        button.onclick = function () {
            timer = setInterval(function () {
                lastBox = document.getElementById("box" + last);
                lastBox.classList.remove("color");
                currentBox = document.getElementById("box" + index);
                currentBox.classList.add("color");
                last = index;
                index = index + 1;
                if (index == numner && circle == 4) {
                    clearInterval(timer);
                }
                if (index > 8) {
                    index = 1;
                    circle = circle + 1;
                }

            }, 200)
        }
    </script>
</body>

</html>